package com.seanchenxi.gwt.xmlrpc.client.impl;

import com.google.gwt.core.client.GWT;
import com.seanchenxi.gwt.xmlrpc.client.ResponseHandler;
import com.seanchenxi.gwt.xmlrpc.client.util.XmlRpcParser;

public class BaseResponseHandler<T> implements ResponseHandler<T> {

	@SuppressWarnings("unchecked")
	@Override
	public T handleResponse(String responseText) {
		try {
			if (responseText != null && responseText.length() > 0) {
				GWT.log(responseText);
				return (T) XmlRpcParser.parserResponse(responseText);
			} else {
				return null;
			}
		} catch (Throwable e) {
			GWT.log("Base Response Handler Error", e);
			return null;
		}
	}
}
